﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Collections.ObjectModel;


namespace ControlExplorer
{
    public class ControlViewModel
    {
        public ControlViewModel() { }

        public ControlViewModel(string name)
        {
            ControlName = name;
            IconTemplate = Application.Current.Resources["IconC1" + ControlName] as ControlTemplate;
            SampleSpecs = new ObservableCollection<SampleSpec>();
            Categories = new List<ControlCat>();
        }

        public string ControlName { get; set; }
        public ControlTemplate IconTemplate { get; set; }

        public List<SampleViewModel> Samples
        {
            get
            {
                // create sample instances every time, to avoid re-parenting issues in the Silverlight framework
                var samples = new List<SampleViewModel>();
                foreach (var spec in SampleSpecs)
                {
                    samples.Add(new SampleViewModel(spec));
                }
                return samples;
            }
        }
        public ObservableCollection<SampleSpec> SampleSpecs { get; set; }

        public List<ControlCat> Categories { get; set; }
    }

}
